home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Video Toaster 4.0
/
Video Toaster v4.0.iso
/
arexx
/
modeler
/
pointsep.lwm
< prev
next >
Wrap
Text File
|
1993-12-13
|
1KB
|
57 lines
/* CMD: Point Separation
*
* By Arnie Cachelin © 1993 NewTek Inc.
* Wed Sep 15 1993
*/
mxx="LWModelerARexx.port"
signal on error
signal on syntax
numeric digits 5
mxx_add = addlib(mxx,0)
call addlib("rexxmathlib.library",0,-30,0)
call main
if (mxx_add) then call remlib(mxx)
exit
syntax:
error:
t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
if (mxx_add) then call remlib(mxx)
exit
main:
call sel_mode(USER)
c=xfrm_begin()
if c~=1 then do
v1=xfrm_getpos(1)
v2=xfrm_getpos(2)
dx=word(v2,1) - word(v1,1)
dy=word(v2,2) - word(v1,2)
dz=word(v2,3) - word(v1,3)
v=dx dy dz
call Notify(1,"!Point Separation:",v,"Distance: "Magnitude(v))
end
else call Notify(1,"!Oops, only one point selected!")
return
Magnitude: PROCEDURE
arg v
return(sqrt(Dot(v,v)))
Dot: PROCEDURE /* vector dot product */
arg v1,v2
S=0
do i=1 to 3
S=S+word(v1,i)*word(v2,i)
end
return S
Dist: PROCEDURE
arg v1,v2
S=0
do i=1 to 3
S=S + (word(v2,i) - word(v1,i))^2
end
return sqrt(S)